<template>
	<el-dialog title="" visible :show-close="false" :modal-append-to-body="false" class="wrap" size="tiny">
		<i class="el-icon-close close" @click="cancel" style="color: white;"></i>
		 <div class="bt">修改</div>
		<el-form label-width="100px" class="form">
			<el-form-item label="名称">
				<el-input v-model="form.mc" placeholder="请输入" class="select-block"></el-input>
			</el-form-item>
			<!-- <el-form-item label="行政老师">
					<el-select v-model="form.xzlsmc" placeholder="请选择行政老师" class="select-block">
						<el-option :label="v.xslsmc" :value="v.xzlsid+''" v-for="v in xzlsList"></el-option>
					</el-select>
			</el-form-item> -->
			<el-form-item label="老师名称">
				<el-select v-model="form.lsmc" class="select-block">
					<el-option :label="v.mc" :value="v.id" v-for="v in comboxlist"></el-option>
				</el-select>
			</el-form-item>
			<el-form-item label="分校课程">
				<el-input v-model="vfxkcidmc" placeholder="请选择分校课程" class="select-block1"  icon="add":readonly="true"></el-input>
				<el-button size="small" @click="showwp()" class="select-block2" >选择</el-button>
			</el-form-item>
			<el-form-item label="教材">
				<el-input v-model="vjcidmc" placeholder="请选择教材名称" class="select-block1" icon="add"  :readonly="true"></el-input>
				<el-button size="small" @click="showjc()" class="select-block2">选择</el-button>
			</el-form-item>
			<el-form-item label="预设人数">
				  <el-input v-model="form.ysbjrs"   class="select-block" ></el-input>
			</el-form-item>
			<el-form-item label="开班日期">
				<el-date-picker  v-model="form.yjkbrq"  type="date" class="select-block" placeholder="选择日期" @keyup.enter.native="search">  </el-date-picker>
			</el-form-item>

			<!-- <el-form-item label="是否启用">
			<el-select v-model="form.isqy"   class="select-block" >
  					  <el-option label="启用" value="Y"></el-option>
  					<el-option label="禁用" value="N" ></el-option>
  			</el-select>
  			</el-form-item> -->
			<!-- <el-form-item label="分校课程ID">
 				<el-input v-model="form.fxkcid"  placeholder="请输入" class="select-block"></el-input>
 			</el-form-item> -->
		</el-form>
		<el-button type="info" class="submit" @click="submit">修改</el-button>
		<PayArticle class="wpfl1" @jcarticle="jcarticleed"  @close="jcarticlecancel" v-if="showarticle"></PayArticle>
		<Kschoose class="wpfl" @wpchoose="wpchooseed" @close="wpchoosecancel" v-if="showchoselist"></Kschoose>
	</el-dialog>
</template>
<script type="text/javascript">
	import qs from 'qs'
	import Kschoose from '../../manage/kssz/kschoose'
	import PayArticle from './pay-articlejc'
	export default {
		props: ['params'],
		components: { Kschoose, PayArticle },
		data() {
			return {
				form: {
					mc: '',
					lsmc: '',
					lsid:'',
					cmc: '',
					jcmc: '',
					isqy: '',
					fxkcid: '',
					id: '',
					xzls:'',
					yjkbrq:'',
				},
				xzlsList: [],
				comboxlist: [],
				showchoselist: false,
				showarticle: false,
				vfxkcidmc:'',
				vjcidmc:'',
			}
		},
		created() {
			this.form.id = this.params.row.id;
			this.vfxkcidmc = this.params.row.fxkcmc;
			this.vjcidmc = this.params.row.jcmc;
			this.getcomboxlist();
			this.loadinfo();
			// this.getxzlsList();
			console.log(this.form)
		},
		methods: {
			// getxzlsList () {
			// 	var logininfo = JSON.parse(localStorage.logininfo);
			// 		this.axios.get( this.$store.state.api + 'ls/xzxzls', {
			// 				params: {
			// 					yhid: logininfo.id,
			// 					xxid:logininfo.xxid
			// 				}
			// 		})
			// 		.then( res => {
			// 				console.log(res)
			// 				this.xzlsList = res.data.data;
			// 		}).catch( res => {
			// 				console.log(res)
			// 		})
			// },
			showwp() {
				this.showchoselist = true;
			},
			showjc() {
				this.showarticle = true;
			},
			wpchooseed(josndata) {
				this.vfxkcidmc = josndata.kcmc;
				this.vfxkcid = josndata.fxkcid;

				this.showchoselist = false;
			},
			jcarticleed(josndata) {
			    this.vcid = josndata.cid;
			    this.vjcid = josndata.jcid;
			    this.vjcidmc = josndata.jcidmc;
				this.showarticle = false;
			},
			wpchoosecancel() {
				this.showchoselist = false;
			},
			jcarticlecancel() {
				this.showarticle = false;
			},
			getcomboxlist() {
				var logininfo = JSON.parse(localStorage.logininfo);
				this.searchLoading = true;
				this.axios.get(this.$store.state.api + 'ls/getlslist', {
					params: {
						yhid: logininfo.id,
						xxid: logininfo.xxid
					}
				}).then(res => {
					console.log(res)
					let data = res.data.data;
					let list = data.list;
					this.comboxlist = list;
					console.log(this.comboxlist)
				}).catch(res => {
					console.log(res)
					this.searchLoading = false;
				})
			},
			loadinfo() {
				var logininfo = JSON.parse(localStorage.logininfo);
				this.axios.get(this.$store.state.api + 'ysbj/info', {
					params: {
						xxid: logininfo.xxid,
						yhid: logininfo.id,
						id: this.form.id
					}
				}).then(res => {
					this.form = res.data.data
				}).catch(res => {
					alert("服务器异常");
					this.$emit('close', { type: 'info', cancel: true });
				})
			},
			submit() {
				//检测
				this.$store.state.loading = true;
				/*if(!this.form.id) {
					this.$message.warning('请填写分类');
					this.$store.state.loading = false;
					return;
				}*/
				//装载数据
				var time1 = this.$.getLocalTimeNo0(Date.parse(this.form.yjkbrq));
				var logininfo = JSON.parse(localStorage.logininfo);
				var params2 = qs.stringify({
					id: this.form.id,
					mc: this.form.mc,
					lsid: this.form.lsid,
					// xzid:this.form.xzlsmc,
					cid: this.vcid,
					isqy: this.form.isqy,
					fxkcid: this.vfxkcid,
					jcid: this.vjcid,
					ysbjrs:this.form.ysbjrs,
					yjkbrq:time1,
					yhid: logininfo.id,
					xxid: logininfo.xxid
				})
				//执行
				this.axios.post(this.$store.state.api + 'ysbj/update', params2)
					.then(res => {
						if(res.data.code == 1) {
							this.$emit('close', { type: 'edit', cancel: false });
							this.$store.state.loading = false;
						} else {
							this.$emit('close', { type: 'edit', cancel: false });
							this.$store.state.loading = false;
						}
					}).catch(res => {
						alert("服务器异常");
						this.$store.state.loading = false;
					})
			},
			cancel() {
				this.$emit('close', { type: 'edit', cancel: true })
			}
		}
	}
</script>
<style lang="less" scoped>
.wrap {
	.row{
		height:50px;
		line-height: 50px;
	}
	.bt{
		position: absolute;
		width: 100%;
		height: 50px;
		margin: 0 auto;
		top: 0;
		left: 0;
		// margin-top: -70px;
		background: #50BFFF;
		// margin-left: -20px;
		// margin-bottom: 20px;
		color:white;
		text-align:left;
		line-height: 50px;
		font-size: 17px;
		padding-left: 15px;
	}
	.close{
			z-index: 10;
			position: absolute;
	}
	.input-block {
		margin-bottom: 20px;
		text-align: center;
	}
	.input {
		width:280px;
		display: inline-block;
		margin-left: 10px;
	}
	.input1 {
		width: 210px;
		display: inline-block;
		margin-left: 10px;
	}
	.input-block span {
		display: inline-block;
		width: 70px;
		text-align: right;
	}
	.submit {
		width: 120px;
		display: block;
		margin: 0 auto;
		margin-top: 20px;
	}
	.wpfl {
		background: #fff;
		position: absolute;
		top: 5px;
		left: 5px;
	}
	.wpfl1 {
		width: 130%;
		background: #fff;
		position: absolute;
		top: 5px;
		left: -66px;
	}
	.form {
		text-align: left;
		margin-top: 20px;
		.select-block {
			width: 85%;
			display: block;
		}
		.select-block1 {
			width: 68%;
			// display: block;
		}
	}
}
</style>
